package com.collection.provider.biz;

import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.collection.api.entity.sys.SysResource;
import com.collection.api.entity.sys.SysUser;
import com.collection.provider.business.dao.sys.SysResourceMapper;
import com.collection.provider.business.dao.sys.SysUserMapper;

@Service
public class ShiroBiz {
	
	@Autowired
    private SysUserMapper sysUserMapper;
    
    @Autowired
    private SysResourceMapper sysResourceMapper;
    
    public List<SysResource> findAllResource() {
        return sysResourceMapper.findAllResource();
    }

    /**
     * 根据角色Id查找资源数据
     * 
     * @param roleId
     * @return
     */
    public List<SysResource> findResourceByRoleId(int roleId) {
        return sysResourceMapper.findResourceByRoleId(roleId);
       
    }

    /**
     * 根据用户名查找用户
     * 
     * @param userName 用户名
     * @return
     */
    public SysUser findByUsername(String userName) {
        if (StringUtils.isBlank(userName)) {
            return null;
        }
        return sysUserMapper.findByUserName(userName,0);
      
    }

}
